import { _decorator, Component, Node } from 'cc';
import EventManager from '../../Init/Managers/EventManager';
import { EventTypes } from '../../Init/Managers/EventTypes';
const { ccclass, property } = _decorator;

@ccclass('GuideLayer')
export class GuideLayer extends Component {

    onLoad() {
        EventManager.on(EventTypes.UIEvents.ShowGuide, this.onShowGuide, this);
    }
    onEnable() {
        this.node.children.forEach(e => {
            e.active = false;
        })
    }

    onShowGuide(name: string) {
        let e = this.node.getChildByName(name);
        if (e) {
            new GuideItem(e);
        }
    }
}

export class GuideItem {
    node: Node;
    delay = 3;
    curt = 0;

    constructor(n: Node) {
        this.node = n;
        this.node.active = true;
        setTimeout(() => {
            this.node.active = false;
        }, this.delay * 1000);
    }


}
